package com.lcredu.dao.impl;

import com.lcredu.dao.BasicDAO;
import com.lcredu.dao.MemberDAO;
import com.lcredu.entity.Member;

/**
 * @author 黎长容
 * @date 2025-07-05 15:50
 */
public class MemberDAOImpl extends BasicDAO<Member> implements MemberDAO {

    @Override
    public Member getMemberByName(String name) {
        String sql = "select * from `member` where `username` = ?";
        return querySingle(sql, Member.class, name);
    }

    @Override
    public int savaMember(Member member) {
        String sql = "insert into `member` values (null,?,MD5(?),?);";
        return update(sql, member.getUsername(), member.getPassword(), member.getEmail());
    }

    @Override
    public Member getMemberByNameAndPwd(Member member) {
        String sql = "select * from `member` where `username` = ? and password = MD5(?)";
        return querySingle(sql,Member.class,member.getUsername(),member.getPassword());
    }
}
